// pages/home/home.js
const request = require("../../utils/request.js")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    swiperImg: '',
    noticeFont: '',
    grid1: '',
    list1:'',
    fabButton: {
      icon: 'share',
      openType: 'share',
    },
    visible: true,
    marquee1: {
      speed: 80,
      loop: -1,
      delay: 0,
    },
    marquee2: {
      speed: 60,
      loop: -1,
      delay: 0,
    },
    grid: [{
        id: 1,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 2,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 3,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 4,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 5,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 6,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 7,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      },
      {
        id: 8,
        image: "/starc/image/圆形图标.png",
        text: "分类名称",
        url: "/pages/logs/logs"
      }
    ],
    list: [{
        id: 1,
        image: "/starc/img/coffee1.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 2,
        image: "/starc/img/coffee2.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 3,
        image: "/starc/img/coffee3.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 4,
        image: "/starc/img/coffee4.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 5,
        image: "/starc/img/coffee1.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 6,
        image: "/starc/img/coffee2.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 7,
        image: "/starc/img/coffee3.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
      {
        id: 8,
        image: "/starc/img/coffee4.png",
        title: "咖啡机咖啡机1",
        text: "产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介:产品简介简介产品简介",
        text2: "265",
        price: "200",
        price1: "500"
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    // 获取轮播图11
    this.getswiperImg();
    // 公告
    this.getNoticeFont();
    // 宫格
    this.getGaidbox();
    // 产品列表
    this.getshopList();
  },
  // 获取轮播图
  getswiperImg() {
    const _this = this
    request.wxRequest('banner/list', function (err, data) {
      // console.log(err, data)
      if (err) {
        // 失败；
      } else {
        _this.setData({
          swiperImg: data.data.image
        })
      }
    }, 'GET', {
      // token:token,
    })
  },
  // 公告
  getNoticeFont() {
    const _this = this
    request.wxRequest('notice/list', function (err, data) {
      // console.log(err, data)
      if (err) {
        // 失败；
      } else {
        _this.setData({
          noticeFont: data.data.list
        })
      }
    }, 'GET', {
      id: 1,
      name: 123
    })
  },
  // 宫格
  getGaidbox() {
    const _this = this
    request.wxRequest('menu/list1', function (err, data) {
      // console.log(data.data.list)
      if (err) {
        // 失败；
      } else {
        _this.setData({
          grid1: data.data.list
        })
      }
    }, 'GET', {
      id: 1,
      name: 123
    })
  },
  // 产品列表
  getshopList() {
    const _this = this
    request.wxRequest('product/list1', function (err, data) {
      // console.log(data.data.list)
      if (err) {
        // 失败；
      } else {
        _this.setData({
          list1: data.data.list
        })
      }
    }, 'GET', {
      id: 1,
      name: 123
    })
  },

  jump: function () {
    wx.navigateTo({
      url: '/pages/index/index',
    })
  },
  jump1: function (e) {
    let det = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/shopList/shopList?det='+det,
      success: ()=>{
        // console.log('成功');
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})